# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-ipaddr
_pkgname=ipaddr
pkgver=5.3.1
pkgrel=1
pkgdesc="A library for manipulation of IP (and MAC) address representations"
provides="ocaml-macaddr=$pkgver-r$pkgrel"
url="https://github.com/mirage/ocaml-ipaddr"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="
	ocaml-runtime
	ocaml-cstruct
	ocaml-domain-name
	ocaml-ppx_sexp_conv
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-cstruct-dev
	ocaml-domain-name-dev
	ocaml-ppx_sexp_conv-dev
	"
makedepends="$depends_dev dune ocaml"
checkdepends="ocaml-ounit-dev ocaml-ppx_sexp_conv-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/ocaml-ipaddr/releases/download/v$pkgver/ipaddr-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	provides="ocaml-macaddr-dev=$pkgver-r$pkgrel"

	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
1d400f8344d1a8c2ac1c55e4a7167484034094e2227ce7c8f2f45843b0875a83030851400ceb96b5cdb756fa8798d83c77d839705fcb9e3f2bd5e46d337d63d0  ocaml-ipaddr-5.3.1.tar.bz2
"
